package cn.edu.sdust.controller;

import cn.edu.sdust.domain.User;
import cn.edu.sdust.service.UserService;
import cn.edu.sdust.serviceImpl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/User")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("login")
    public String login(User user, Model model){

        System.out.println("name:"+user.getName());
        System.out.println("password:"+user.getPassword());
        List<User> list = userService.getAllUser();
        for(int i=0;i<list.size(); i++){
            System.out.println("id:"+list.get(i).getId()+", name:"+list.get(i).getName()+", password:"+list.get(i).getPassword());
        }
        model.addAttribute("users",list);
        return "hello";
    }
    @RequestMapping("index")
    public String index(){
        return "hello";
    }
}
